package pictionary2;

//que pedo puerco xD


import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import java.net.UnknownHostException;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author Viper
 */
public class ServidorMSN extends MSN{
    private ServerSocket ss;

    public ServidorMSN() throws Exception {
        super("Servidor", new EscuchadorEvento());
        iniciaServidor();
    }
    private void iniciaServidor() throws Exception{
        ss= new ServerSocket(9999);
        //Socket s= new Socket("localhost",9999);
        System.out.println("Esperando conexion en el puerto 9999 "+ ss.getInetAddress());
        while(true){
            Socket aux= ss.accept();
            new Thread(new Escuchador(aux, this)).start();
            //**new Thread(new Escritor(aux)).start();
            getEe().setMsn(this);
            getEe().setS(aux);
            //new Thread(new Servidor2(ss.accept(),"escritor")).start();
        }
    }
    public static void main(String[] args) throws UnknownHostException, IOException, Exception {
        ServidorMSN servidorMSN = new ServidorMSN();
    }

}
